package hn.sigit.dao.ladm.party;

import hn.sigit.model.ladm.external.ExtParty;
import hn.sigit.model.ladm.party.LA_Party;
import hn.sigit.dao.SigitDAO;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.jboss.seam.Component;

public class LA_PartyDAO extends SigitDAO<ExtParty> {
	private static final long serialVersionUID = 1L;
	
	protected LA_PartyDAO() {
	}

	public static LA_Party loadPartyByExtParty(ExtParty extParty) {
		Session commonsDatabase = (Session)Component.getInstance(COMMONS_DB);
		return loadPartyByExtParty(commonsDatabase, extParty);
	}

	public static LA_Party loadPartyByExtParty(Session session, ExtParty extParty) {
		Criteria criteria = session.createCriteria(LA_Party.class);
		criteria.add(Restrictions.isNull("endLifespanVersion"));
		criteria.add(Restrictions.eq("extParty", extParty));

		return (LA_Party)criteria.uniqueResult();
	}

	/*
	public LA_Party createLA_Party() {
		return new LA_Party();
	}
	
	public void save(LA_Party laParty) {
		commonsDatabase.saveOrUpdate(laParty);
	}
	
	public void delete(LA_Party laParty) {
		commonsDatabase.delete(laParty);
	}
*/
}
